﻿<!-- Copyright (c) 2008 Thomas Gerber
 Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), 
 to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, 
 and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
 The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
 OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
 BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 
 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.-->
<!--
    Changelog
    Version 1.3.17
    
    Changed Width="{TemplateBinding Width}" to Width="{TemplateBinding ActualWidth}" to enable text wrapping.
    Found by chaiguy1337:
    http://www.codeproject.com/KB/WPF/WPFExplorerBar.aspx?fid=1527421&select=2850083#xx2850083xx
    thanx for your help.
    -->
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:odc="clr-namespace:Odyssey.Controls" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
    <Duration x:Key="animTime">0:0:0.20</Duration>
    <Style TargetType="{x:Type odc:OdcExpander}">
        <Setter Property="Background" Value="#40808080" />
        <Setter Property="BorderBrush" Value="#60404040" />
        <Setter Property="HeaderBackground" Value="#40A0A0A0" />
        <Setter Property="MouseOverHeaderBackground" Value="#60FFFFFF" />
        <Setter Property="MouseOverHeaderForeground" Value="#F0000000" />
        <Setter Property="odc:KeyTip.Stop" Value="false" />
        <Setter Property="odc:KeyTip.YOffset" Value="2" />
        <Setter Property="odc:KeyTip.XOffset" Value="-24" />
        <Setter Property="HeaderBorderThickness" Value="1" />
        <Setter Property="CornerRadius" Value="0" />
        <Setter Property="ShowEllipse" Value="True" />
        <Setter Property="BorderThickness" Value="1,0,1,1" />
        <Setter Property="Padding" Value="8" />
        <Setter Property="Template">

            <Setter.Value>
                <ControlTemplate TargetType="{x:Type odc:OdcExpander}">
                    <Border BorderThickness="{TemplateBinding HeaderBorderThickness}"
                            Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}"
                            CornerRadius="{TemplateBinding CornerRadius}">
                        <Grid>
                            <Grid.RowDefinitions>
                                <RowDefinition Height="Auto" />
                                <RowDefinition Height="*" />
                            </Grid.RowDefinitions>
                            <odc:OdcExpanderHeader x:Name="header" Grid.Row="0" Content="{TemplateBinding Header}" 
                                    IsChecked="{Binding RelativeSource={RelativeSource TemplatedParent},Path=IsExpanded}"
                                    ContentTemplate="{TemplateBinding HeaderTemplate}"
                                    Background="{TemplateBinding HeaderBackground}"
                                    ShowEllipse="{TemplateBinding ShowEllipse}"
                                    CornerRadius="{TemplateBinding CornerRadius}" Image="{TemplateBinding Image}" />
                            <Border x:Name="panel" Grid.Row="1" Panel.ZIndex="-1" Margin="0,-1,0,0"
                                    Opacity="{Binding ElementName=decorator, Path=AnimationOpacity}"
                                    Background="{TemplateBinding Background}"
                                    BorderThickness="{TemplateBinding BorderThickness}">
                                <odc:AnimationDecorator x:Name="decorator" VerticalAlignment="Top"
                                        Duration="{StaticResource animTime}" MinHeight="{TemplateBinding MinHeight}"
                                        MaxHeight="{TemplateBinding MaxHeight}" Height="{TemplateBinding Height}"
                                        IsExpanded="{Binding RelativeSource={RelativeSource TemplatedParent},Path=IsExpanded}">
                                    <Border Padding="{TemplateBinding Padding}">
                                        <ContentPresenter Content="{TemplateBinding Content}"
                                                ContentTemplate="{TemplateBinding ContentTemplate}" />
                                    </Border>
                                </odc:AnimationDecorator>
                            </Border>

                        </Grid>
                        <Border.LayoutTransform>
                            <ScaleTransform x:Name="scaleT" ScaleY="1" />
                        </Border.LayoutTransform>
                    </Border>

                    <ControlTemplate.Triggers>
                        <Trigger Property="IsHeaderVisible" Value="False">
                            <Setter TargetName="header" Property="Visibility" Value="Collapsed" />
                        </Trigger>
                        <Trigger Property="IsMouseOver" Value="True" SourceName="header">
                            <Setter Property="Foreground"
                                    Value="{Binding RelativeSource={RelativeSource TemplatedParent},Path=MouseOverHeaderForeground}"
                                    TargetName="header" />
                            <Setter Property="Background"
                                    Value="{Binding RelativeSource={RelativeSource TemplatedParent},Path=MouseOverHeaderBackground}"
                                    TargetName="header" />
                        </Trigger>
                        <MultiTrigger>
                            <MultiTrigger.Conditions>
                                <Condition Property="IsPressed" Value="True" SourceName="header" />
                                <Condition Property="HasPressedBackground" Value="True" />
                            </MultiTrigger.Conditions>
                            <Setter Property="Background"
                                    Value="{Binding RelativeSource={RelativeSource TemplatedParent},Path=PressedHeaderBackground}"
                                    TargetName="header" />
                        </MultiTrigger>
                        <EventTrigger RoutedEvent="odc:OdcExpander.MaximizedEvent">
                            <EventTrigger.Actions>
                                <BeginStoryboard>
                                    <Storyboard Storyboard.TargetProperty="ScaleY">
                                        <DoubleAnimation To="1" Duration="{StaticResource animTime}"
                                                Storyboard.TargetName="scaleT" DecelerationRatio="0.8" />
                                    </Storyboard>
                                </BeginStoryboard>
                            </EventTrigger.Actions>
                        </EventTrigger>
                        <EventTrigger RoutedEvent="odc:OdcExpander.MinimizedEvent">
                            <EventTrigger.Actions>
                                <BeginStoryboard>
                                    <Storyboard Storyboard.TargetProperty="ScaleY">
                                        <DoubleAnimation To="0" Duration="{StaticResource animTime}"
                                                Storyboard.TargetName="scaleT" DecelerationRatio="0.8" />
                                    </Storyboard>
                                </BeginStoryboard>
                            </EventTrigger.Actions>
                        </EventTrigger>
                    </ControlTemplate.Triggers>
                    <ControlTemplate.Resources>
                        <Style TargetType="{x:Type TreeViewItem}">
                            <Setter Property="Template"
                                    Value="{DynamicResource {ComponentResourceKey odc:Skins, TreeViewItemTemplate}}" />
                        </Style>
                        <Style TargetType="{x:Type ListViewItem}">
                            <Setter Property="Template"
                                    Value="{DynamicResource {ComponentResourceKey odc:Skins, ListViewItemTemplate}}" />
                        </Style>
                    </ControlTemplate.Resources>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

</ResourceDictionary>